DECLARE @intProductId INT

DECLARE CUR_ CURSOR LOCAL FAST_FORWARD FOR 
SELECT Id FROM Product
WHERE (LatestInputPrice IS NULL OR LatestInputPrice = 0)
AND  EXISTS (SELECT 1 FROM InProdDetail
					WHERE ProductId = Product.Id)
OPEN CUR_
 
FETCH NEXT FROM CUR_
INTO @intProductId
  

WHILE @@FETCH_STATUS = 0
BEGIN
	PRINT @intProductId
	EXEC pUpdateLatestInputPriceOfProduct
		@vintProductId = @intProductId
	FETCH NEXT FROM CUR_ INTO @intProductId

END

CLOSE CUR_
DEALLOCATE CUR_